import React from 'react';
import {
    Form,
    Input,
    DatePicker,
    Select,
    Cascader,
    Row,
    Col,
    Checkbox,
    Button,
    Modal,
    Table,
    Pagination,
    Radio,
    Icon,
    Collapse,
    Upload,
    message
} from 'antd';
import util from 'util';
import $ from 'jquery';
import sys_dict from "sys_dict";

const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const Option = Select.Option;
const CheckboxGroup = Checkbox.Group;
const Panel = Collapse.Panel;

//搜索面板---
@Form.create()
class BatchDetail extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            tblSource: [],
            totalCount: 0,
            isLoading: false,
        };
        // 初始化查询参数
        this.searchParams={
        };
    }

    // 渲染之后
    componentDidMount() {
        this.searchParams=this.props.searchParams;
        this.refresh(this.searchParams);
    }

    // 刷新 wqdqwe1231231
    refresh(paramdic) {
        // 打开等待框
        this.setState({isLoading: true});
        util.httpRequest({
            type: "POST", url: 'task050603.json', params: paramdic,
            success: function (result) {
                if (result.ret_code == "0000") {
                    this.setState({
                        tblSource: result.rows,
                    });
                }
            }.bind(this)
        });
    }

    reset(e) {
        e.preventDefault();
    }

    // pagesize改变
    onShowSizeChange(current, pageSize) {
        console.log(current, pageSize);
        let params = this.searchParams;
        params.rows = pageSize;
        params.page = current;
        this.refresh(params);
    }
    // page改变
    onChange(page) {
        console.log(page);
        let params = this.searchParams;
        params.page = page;
        this.refresh(params);
    }

    config() {
        const pagination = {
            total: this.state.totalCount,
            showSizeChanger: true,
            showQuickJumper: true,
            pageSizeOptions: sys_dict.pageSizeOptions,
            defaultPageSize: sys_dict.defaultPageSize,
            onShowSizeChange: this.onShowSizeChange.bind(this),
            onChange: this.onChange.bind(this)
        };
        // 返回列表配置 1
        return {
            tableConfig: {
                dataSource: this.state.tblSource,
                columns: [ {
                    title: '项目编号',
                    dataIndex: 'projectid',
                    key: 'projectid',
                    width:"110"
                }, {
                    title: '项目名称',
                    dataIndex: 'projectname',
                    key: 'projectname',
                    width:"100"
                },{
                    title: '任务编号',
                    dataIndex: 'jobid',
                    key: 'jobid',
                    width:"110"
                }, {
                    title: '任务名称',
                    dataIndex: 'jobname',
                    key: 'jobname',
                    width:"110"
                }, {
                    title: '执行顺序',
                    dataIndex: 'exeorder',
                    key: 'exeorder',
                    width:"110"
                }, {
                    title: '状态',
                    dataIndex: 'status',
                    key: 'status',
                    render: function (value, data, rowIndex) {
                        var str = util.convert("job_status", value);
                        return str;
                    }
                }, {
                    title: '返回结果',
                    dataIndex: 'result',
                    key: 'result',
                    width:"110"
                }]
            }
        };
    }

    render() {
        const {getFieldProps, getFieldValue} = this.props.form;
        var title = getFieldProps("title");
        var content = getFieldProps("content");
        var createdatestart = getFieldProps("createdatestart");
        var createdateend = getFieldProps("createdateend");
        var updatedatestart = getFieldProps("updatedatestart");
        var updatedateend = getFieldProps("updatedateend");

        let config = this.config();

        return (
           <div>
               <Table {...config.tableConfig}></Table>
           </div>
        );
    }
}

export {BatchDetail}
